# Maintainer: Henrik Grimler <henrik@grimler.se>
# Reference: <https://postmarketos.org/devicepkg>
pkgname=device-samsung-klimtlte
pkgdesc="Samsung Galaxy Tab S 8.4 LTE"
pkgver=4
pkgrel=0
url="https://postmarketos.org"
license="MIT"
arch="armv7"
options="!check !archcheck"
depends="
	postmarketos-base
	mkbootimg
"
makedepends="devicepkg-dev"
source="deviceinfo"
subpackages="
	$pkgname-kernel-downstream:kernel_downstream
	$pkgname-kernel-mainline:kernel_mainline
	$pkgname-nonfree-firmware:nonfree_firmware
	$pkgname-nonfree-firmware-downstream:nonfree_firmware_downstream
	$pkgname-nonfree-firmware-mainline:nonfree_firmware_mainline
"

build() {
	devicepkg_build $startdir $pkgname
}

package() {
	devicepkg_package $startdir $pkgname
}

kernel_downstream() {
	pkgdesc="Display works, wifi is broken (see device table for details)"
	depends="
		linux-samsung-klimtlte
		msm-fb-refresher
		postmarketos-base-downstream
	"
	devicepkg_subpackage_kernel $startdir $pkgname $subpkgname
}

kernel_mainline() {
	pkgdesc="Mainline WIP (usb networking and wifi works but not much else)"
	depends="linux-postmarketos-exynos5"
	devicepkg_subpackage_kernel $startdir $pkgname $subpkgname
}

nonfree_firmware() {
	pkgdesc="Non-free firmware for the Samsung Galaxy Tab S 8.4"
	mkdir "$subpkgdir"
}

nonfree_firmware_downstream() {
	pkgdesc="Non-free firmware for klimtlte when using downstream kernel"
	install_if="$pkgname=$pkgver-r$pkgrel $pkgname-nonfree-firmware=$pkgver-r$pkgrel $pkgname-kernel-downstream"
	depends="firmware-samsung-klimt-downstream>=3.0-r0"
	mkdir "$subpkgdir"
}

nonfree_firmware_mainline() {
	pkgdesc="Non-free firmware for klimtlte when using mainline kernel"
	install_if="$pkgname=$pkgver-r$pkgrel $pkgname-nonfree-firmware=$pkgver-r$pkgrel $pkgname-kernel-mainline"
	depends="firmware-samsung-klimt-mainline>=3.0-r0"
	mkdir "$subpkgdir"
}

sha512sums="
1d90ff9d62176f063c8ca13d7a492002269726e438e16e76d6be29609fa6aef5e1d8e4414482f068c8e0223d220c2af7c87c8c94876d621d62b2fbc4e7bb7e92  deviceinfo
"
